<include file="Public/header1" title="专题内容管理" />


<div class="main">
    <div class="wrap">
        <div class="content">
            <div class="nav">
                <ul class="nav-pills">
                    <li><a href="{:U('Reporter/index')}">首页</a></li>
                    <li><a href="{:U('Special/index')}">专题管理</a></li>
                    <li><a href="javascript:;">直播管理</a></li>
                </ul>
                <div class="nav-menu">
                    <a class="navbtn add"><span>添加</span></a>
                    <a class="navbtn topic" id="topicAddress"><span>专题地址</span></a>
                    <form id="search-form" action="{:U('details')}">
                        <input type="hidden" name="id" value="{$Think.get.id}" />
                    <div class="date-choose">
                        <div class="date-item">
                            <div class='input-group date' id='datetimepicker1'>
                                <input type='text' class="form-control" name="s_time" value="{$Think.get.s_time}" />
                                <span class="input-group-addon">
                                <span class="glyphicon glyphicon-calendar"></span>
                            </span>
                            </div>
                        </div>
                        <span class="date-text">至</span>
                        <div class="date-item">
                            <div class='input-group date' id='datetimepicker2'>
                                <input type='text' class="form-control" name="e_time" value="{$Think.get.e_time}" />
                                <span class="input-group-addon">
                                <span class="glyphicon glyphicon-calendar"></span>
                            </span>
                            </div>
                        </div>
                    </div>
                    <div class="search">
                        <input type="text" class="search-inner" name="title">
                        <div class="search-icon" id="search-btn">
                            <i></i>
                        </div>
                    </div>
                    </form>
                </div>
            </div>
            <table class="topics">
                <thead>
                <tr>
                    <th class="c-title"></th>
                    <th>预览图</th>
                    <th>标题</th>
                    <th>开始时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <foreach name="list" item="val">
                <tr>
                    <td class="c-title"><input name="id" type="checkbox" value="{$val.spec_re_id}" class="np" /></td>
                    <td class="topic-img">
                        <img width="100%" height="100%" src="{$val.image_url|default='http://jianwei.appwuhan.net/Public/images/defaultpic.gif'}" alt="">
                    </td>
                    <td>
                        <a href="{:U('Live/liveinfo')}?group_id={$val.group_id}&sid={$val.spec_id}">{$val.title}</a>
                    </td>
                    <td>
                        {$val.start_time|date="Y-m-d H:i",###}
                    </td>
                    <td>
                        <a href="{:U('Special/reCall')}?id={$val.spec_re_id}">撤回</a>
                    </td>
                </tr>
                </foreach>
                </tbody>
            </table>
            <div class="menu">
                <div class="checkAll pull-left"><input type="checkbox" id="checkAll"/></div>
                <div class="submenu pull-left">
                    <!--<a class="btn">签发</a>-->
                    <a class="btn" id="recall">撤回</a>
                </div>
            </div>
            <div class="controls">
                <div class="pagers">
                    {$showpage}
                </div>

            </div>
        </div>
    </div>
</div>
<div class="live-modal">
    <div class="title">选择内容</div>
    <iframe id="ifComment" src="{:U('Home/Special/getIssueLive')}?spec_id={$Think.get.id}" width="100%" height="800" frameborder="0"></iframe>
</div>
<div id="alert-msg"></div>
<div id="mask" unselectable="on"></div>

<div class="modal fade" tabindex="-1" role="dialog" id="topicAddressBox">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">专题地址</h4>
            </div>
            <div class="modal-body">
                <p>http://plive.appwuhan.com/userThemeList?tid={$Think.get.id}</p>
            </div>
        </div>
    </div>
</div>

<script>

    $(function(){

        $('#topicAddress').on('click', function (e) {
            $('#topicAddressBox').modal('show')
        })

        $("#checkAll").click(function(){
//            debugger;
            if($(this).is(":checked")){
                $(".topics").find('input').prop("checked",true);
            }else{
                $(".topics").find('input').prop("checked",false);
            }
        });

        $(".topic-title").ellipsis({
            row: 2
        });
        $(".topic-content").ellipsis({
            row: 2
        });

        // 模态框

        $(document).on("click",".live-modal .item",function () {
            $(this).toggleClass("active");
        });

        // 模态框里面的时间控件
        $('#datetimepicker3').datetimepicker({
            format: "YYYY-MM-DD"
        });
        $('#datetimepicker4').datetimepicker({
            format: "YYYY-MM-DD",
            useCurrent: false //Important! See issue #1075
        });

        $("#datetimepicker3").on("dp.change", function (e) {
            $('#datetimepicker4').data("DateTimePicker").minDate(e.date);
        });
        $("#datetimepicker4").on("dp.change", function (e) {
            $('#datetimepicker3').data("DateTimePicker").maxDate(e.date);
        });


        //添加按钮
        $(".add").click(function () {
            $(".live-modal").css("visibility","visible");
            $(".live-modal").addClass('on');
            $("#mask").show();
            $(".content-title").ellipsis({
                row: 2
            });
//            $('#ifComment').contents().find(".submit").click(function(e){
//                var num = setInterval(function () {
//                    alert($('#alert-msg').html());
//                    clearTimeout(num);
//                    $(".live-modal").removeClass('on');
//                    $("#mask").hide();
//                    window.location.href = '{:U("details")}?id={$Think.get.id}';
//                }, 500);
////                console.log(123)
//            })
//
//            $('#ifComment').contents().find(".cancel").click(function(e){
//                $(".live-modal").removeClass('on');
//                $("#mask").hide();
//            })
        });

        //取消编辑
        $("#mask,.live-modal .cancel").click(function () {
            $(".live-modal").removeClass('on');
            $("#mask").hide();
        });

        // 时间控件
        $('#datetimepicker1').datetimepicker({
            format: "YYYY-MM-DD"
        });
        $('#datetimepicker2').datetimepicker({
            format: "YYYY-MM-DD",
            useCurrent: false //Important! See issue #1075
        });

        $("#datetimepicker1").on("dp.change", function (e) {
            $('#datetimepicker2').data("DateTimePicker").minDate(e.date);
        });
        $("#datetimepicker2").on("dp.change", function (e) {
            $('#datetimepicker1').data("DateTimePicker").maxDate(e.date);
        });


        $('#search-btn').click(function () {
            $("#search-form").submit();
        });

        $('#recall').click(function(){
            if(confirm('是否确定撤回？')){
                var id=$('[name=id]:checked').map(function(){
                    return $(this).val();
                }).get().join()

                $.post('{:U("reCall")}',{"id":id,spec_id:'{$Think.get.id}'},function(data){
                    if(data.status==1){
//                        $('[name=id]:checked').parents('tr').remove();
                        window.location.href = '{:U("details")}?id={$Think.get.id}';
                    }
                })
            }
        });

    })
</script>
</body>
</html>